#ifndef QSIGNALHANDLER_H
#define QSIGNALHANDLER_H

#include <QObject>
#include <QSocketNotifier>

int setup_unix_signal_handlers();

class QSignalHandler : public QObject
{
    Q_OBJECT
public:
    explicit QSignalHandler(QObject *parent = nullptr);
    virtual ~QSignalHandler();

public:
    // Unix signal handlers.
    static void hupSignalHandler(int );
    static void termSignalHandler(int );
    static void intSignalHandler(int );
    static void contSignalHandler(int );

public slots:
    // Qt signal handlers.
    void handleSigHup();
    void handleSigTerm();
    void handleSigInt();
    void handleSigCont();

private:
    static int sighupFd[2];
    static int sigtermFd[2];
    static int sigintFd[2];
    static int sigcontFd[2];

    QSocketNotifier *snHup;
    QSocketNotifier *snTerm;
    QSocketNotifier *snInt;
    QSocketNotifier *snCont;
};

#endif // QSIGNALHANDLER_H
